package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.java.mvcframework.annotations.LagouAurowired;
import com.lagou.java.mvcframework.annotations.LagouController;
import com.lagou.java.mvcframework.annotations.LagouRequestMapping;
import com.lagou.java.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Security("老大")
@LagouController
@LagouRequestMapping("/demo")
public class DemoController {

    @LagouAurowired
    private IDemoService iDemoService;

    @Security("张三")
    @LagouRequestMapping("/query")
    public String query(HttpServletRequest request, HttpServletResponse response, String name) throws Exception {
        String s = iDemoService.get(name);
        System.out.println("name>>>" + name);
        response.setContentType("text/html;charset=UTF-8");
        response.getWriter().write("请求成功!");
        return name;
    }

    @Security("lisi")
    @LagouRequestMapping("/show")
    public String show(HttpServletRequest request, HttpServletResponse response, String name) throws Exception {
        String s = iDemoService.get(name);
        System.out.println("name>>>" + name);
        response.setContentType("text/html;charset=UTF-8");
        response.getWriter().write("让我们一起摇摆, 摇摆摇摆....");
        return name;
    }
}
